<?php
/**
 * {Login.php}
 *
 * Author: asuslx (asuslx@gmail.com)
 * Date: 9/4/12
 */
 
class Ctrl_Login extends F_App_Controller {

    protected $params = array(

        'Index' => array(
            array('name' => 'email', 'type' => 'str'),
            array('name' => 'password', 'type' => 'str'),
            array('name' => 'submit', 'type' => 'str'),
        ),
    );

    function _initialize() {

        $this->frame = new Frame_Unsigned();
    }

    protected function onException(Exception $e) {

	    header ("Location: error.html");
    }

    function action404($params) {

    }

    function actionIndex($params) {
	if ($params['submit']) {
		if (!BK_User::instance() -> login($params['email'], $params['password'])) {
			$this -> _assign("error", BK_User::instance() -> getLastError());		
		} else {
			header ("Location: /");
			exit();
		}
	}
    }

    function actionReminder($params) {

    }

    function actionSignout($params) {
		BK_User::instance() -> logout();
		header ("Location: /");
		exit;
    }

}
